// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.worldMap.styles;

import java.util.ArrayList;
import zombie.core.textures.Texture;
import zombie.worldMap.WorldMapFeature;

public class WorldMapTextureStyleLayer extends WorldMapStyleLayer {
    public int m_worldX1;
    public int m_worldY1;
    public int m_worldX2;
    public int m_worldY2;
    public boolean m_useWorldBounds = false;
    public final ArrayList<WorldMapStyleLayer.ColorStop> m_fill = new ArrayList();
    public final ArrayList<WorldMapStyleLayer.TextureStop> m_texture = new ArrayList();
    public boolean m_tile = false;

    public WorldMapTextureStyleLayer(String id) {
        super(id);
    }

    @Override
    public String getTypeString() {
        return "Texture";
    }

    @Override
    public boolean filter(WorldMapFeature feature, WorldMapStyleLayer.FilterArgs args) {
        return false;
    }

    @Override
    public void render(WorldMapFeature feature, WorldMapStyleLayer.RenderArgs args) {
    }

    @Override
    public void renderCell(WorldMapStyleLayer.RenderArgs args) {
        if (this.m_useWorldBounds) {
            this.m_worldX1 = args.renderer.getWorldMap().getMinXInSquares();
            this.m_worldY1 = args.renderer.getWorldMap().getMinYInSquares();
            this.m_worldX2 = args.renderer.getWorldMap().getMaxXInSquares() + 1;
            this.m_worldY2 = args.renderer.getWorldMap().getMaxYInSquares() + 1;
        }

        WorldMapStyleLayer.RGBAf rGBAf = this.evalColor(args, this.m_fill);
        if (rGBAf.a < 0.01F) {
            WorldMapStyleLayer.RGBAf.s_pool.release(rGBAf);
        } else {
            Texture texture = this.evalTexture(args, this.m_texture);
            if (texture == null) {
                WorldMapStyleLayer.RGBAf.s_pool.release(rGBAf);
            } else {
                if (this.m_tile) {
                    args.drawer.drawTextureTiled(texture, rGBAf, this.m_worldX1, this.m_worldY1, this.m_worldX2, this.m_worldY2, args.cellX, args.cellY);
                } else {
                    args.drawer.drawTexture(texture, rGBAf, this.m_worldX1, this.m_worldY1, this.m_worldX2, this.m_worldY2);
                }

                WorldMapStyleLayer.RGBAf.s_pool.release(rGBAf);
            }
        }
    }
}
